<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  <style>
  .aligns{text-align:center}
  .right{float:right}
  </style>
  <title>e网批发管理后台</title>
  <link type="text/css" rel="stylesheet" href="time/css/lanrenzhijia.css" />
  <link rel="stylesheet" type="text/css" href="time/css/jquery-ui.css" />
  <script type="text/javascript" src="js/jquery.min.js"></script>
  <script src="time/js/jquery-ui-1.10.4.custom.min.js"></script>
  <script src="time/js/jquery.ui.datepicker-zh-CN.js"></script>
  <script src="time/js/jquery-ui-timepicker-addon.js"></script>
  <script src="time/js/jquery-ui-timepicker-zh-CN.js"></script>
  <script language="javascript" type="text/javascript" src="datepicker/WdatePicker.js"></script>
  <title>e网批发管理后台</title>
  <?php include("common/conn.php"); if($_SESSION['userid']==""){echo "<script>window.location.href='login.php';</script>";} 


  // 获取时间
if (isset($_REQUEST['date']) && isset($_REQUEST['dateL'])) {
  $date=$_REQUEST['date'];
  $dateL=$_REQUEST['dateL'];
  $date=date("Y-m-d",strtotime($date));
  $lateL=date("Y-m-d",strtotime($dateL));
  $between=" and created_at>'".$date."' and created_at<'".$lateL."'";
}else{
  $date=date("Y-m-d",(time() - 3600*24*15));
  $dateL=date("Y-m-d",(time() + 3600*24));
  $between=" and created_at>'".$date."' and created_at<'".$dateL."'";
}

$uid = ($_REQUEST['uid']!='') ? " uid=$_REQUEST['uid'] " : '';
$sid = ($_REQUEST['sid']!='') ? " sid=$_REQUEST['sid'] " : '';

switch ($_REQUEST['cateid']) {
  case '1':
    $cid=" and active_pay<>2 ";
    break;

  case '2':
    $cid=" and active_pay=2 ";
    break;

  default:
    $cid="";
    break;
}

  ?>
  <script type="text/javascript" src="js/jquery.min.js"></script>
  <link href="css/styles.css" rel="stylesheet" type="text/css" />
  <link href="css/style2.css" rel="stylesheet" type="text/css" />

  <script type="text/JavaScript">
    <!--
function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}
//-->
</script>
</head>

<body>

  <!--header-->
  <?php include("common/header.php");?>
  <!--header end-->

  <!-- staqrt subnav -->
  <div id="sub_nav">

    <div id="subnav_wrap" class="container_12">

      <!-- start sub nav list -->
      <div id="subnav" class=" grid_12">
        <ul>
          <li><a href="wallet.php?t=shop" <?php if($_GET['t']!='user'){ ?> class='sub_nav_active'<?php }?> >返回 店铺钱包</a></li>
          <li><a href="wallet.php?t=user" <?php if($_GET['t']=='user'){ ?> class='sub_nav_active'<?php }?> >返回 用户钱包</a></li>
        </ul>
      </div>

    </div>

  <div class="container_12 aligns" >

    <form style="width:100%" action="" method="post">
      <span>开始时间</span>
      <input name="date" type="text" value="<?php echo $date; ?>" style="cursor:pointer;" onClick="WdatePicker()"/>
      &nbsp;&nbsp;&nbsp;
      <span>结束时间</span>
      <input name="dateL" type="text" value="<?php echo $dateL; ?>" style="cursor:pointer;" onClick="WdatePicker()"/>

      <label>分类</label> 
      <select name='categroys' class="select categroys">
        <option selected value="4">全部分类</option>
        <option <?php if($_REQUEST[cateid] == '1'){ ?> selected <?php } ?> value="1">收入</option>
        <option <?php if($_REQUEST[cateid] == '2'){ ?> selected <?php } ?> value="2">提现</option>
      </select>
      <input type="submit" value="提交" class="submit">
    </form>
  </div>

  </div>
  <div class="container_12">
    <!-- <input type="button" class="submit" value="新增热词" onclick="add();"> -->
  </div>
  <!-- end sub_nav -->
  <div class="container_12" style="background: #fff; border:0px; position:relative">

  </div>
    <form action="?del=ok" method="post">
      <div class="container_12">

        <table width="100%" border="0" cellpadding="0" cellspacing="0">
          <tr class='even'>
            <th width="5%" scope="col">
              <input type="checkbox" name="checkbox" id="checkbox" class="checkall" /><label for="checkbox"></label></th>
              <!-- <th width="13%" scope="col">ID</th> -->
              <th width="13%" scope="col">单号</th>
              <th width="18%" scope="col">金额</th>
              <!-- <th width="13%" scope="col">状态</th> -->
              <th width="13%" scope="col">时间</th>
          </tr> 
            
            <?php 
            mysql_query('SET NAMES UTF8');  

            $ren="1";
            $sex="0";
$perNumber=20; //每页显示的记录数
$page=$_GET['page']; //获得当前的页面值
if($_REQUEST['t']=="users" && $_REQUEST['uid'])
{
  $count=mysql_query("select count(*) from user_pay where ".$uid.$cid.$between);
}else if($_REQUEST['t']=="shops" && $_REQUEST['sid']){
  $count=mysql_query("select count(*) from shop_pay where ".$sid.$cid.$between);
}

if(isset($_REQUEST['uid'])){ 
  $usid=$_REQUEST['uid'];
}
if(isset($_REQUEST['sid'])){
  $ssid=$_REQUEST['sid'];
}


//获得记录总数
$rs=mysql_fetch_array($count); 
$totalNumber=$rs[0];
$totalPage=ceil($totalNumber/$perNumber); //计算出总页数

if (!isset($page)) {
  $page=1;
} //如果没有值,则赋值1
$startCount=($page-1)*$perNumber; //分页开始,根据此方法计算出开始的

if ($_REQUEST['t']=="users" && $_REQUEST['uid']) {
  $rert30=mysql_query("select * from user_pay where uid=".$_REQUEST['uid'].$between.$cid." limit $startCount,$perNumber");
}else if($_REQUEST['t']=="shops" && $_REQUEST['sid']){
  $rert30=mysql_query("select * from shop_pay where sid=".$_REQUEST['sid'].$between.$cid." limit $startCount,$perNumber");
}					

while($sdg30=mysql_fetch_assoc($rert30)){

  ?>

  <tr class='even'>

    <td width="13%" scope="col"><input type="checkbox" name="checkbox[]" id="checkbox"  value="<?php if($_GET['t']=='users'){ echo $sdg30[uid];}elseif($_GET['t']=='shops'){ echo $sdg30[sid]; };?>"/></td>
    <td width="13%" scope="col"><?php echo $sdg30[numbers];?></td>
<!--     <td width="13%" scope="col"><?php if($_GET['t']=='users'){ echo $sdg30[uid];}elseif($_GET['t']=='shops'){ echo $sdg30[sid]; };?></td> -->
    <td width="13%" scope="col"> <?php if($sdg30[active_pay] == '2'){echo '-';}else{echo '+';} ?> <?php echo $sdg30[amount];?></td>
    <!-- <td scope="col"><a href="walletDetail.php?detail=1&<?php if($_GET['t']=='user'){echo 'uid';}else{echo 'sid';} ?>=<?php if($_GET['t']=='user'){ echo $sdg30[uid];}else{ echo $sdg30[sid]; };?>">查看详情</a></td> -->
    <td width="13%" scope="col"><?php echo $sdg30[created_at];?></td>
  </tr> 



  <?php }?>
</table>
<div class="grid_12">

  <div class="clearfix"><!-- <input name="" type="submit" value="删除选中" class="submit"/> --></div>

  <ul id="pagination">



    <?php  

    if ($page > 1) { //上一页 ?>
    <li><a href="?<?php if($_REQUEST[t]=='users' && $_REQUEST[uid]){echo 't=users&uid='.$usid.'&';}else{echo 't=shops&sid='.$ssid.'&';} ?>page=1&keywords=<?php echo $_REQUEST[keywords]; ?>">首页</a></li>
    <li><a href="?<?php if($_REQUEST[t]=='users' && $_REQUEST[uid]){echo 't=users&uid='.$usid.'&';}else{echo 't=shops&sid='.$ssid.'&';} ?>page=<?php echo ($page-1); ?>&keywords=<?php echo $_REQUEST[keywords]; ?>">上一页</a></li>
    <?php }

    ?>

    <li class="active"><?php echo $page;?></li>

    <?php



    if ($_GET[page]!=$totalPage) { //下一页 ?>
    <li><a href="?<?php if($_REQUEST[t]=='users' && $_REQUEST[uid]){echo 't=users&uid='.$usid.'&';}else{echo 't=shops&sid='.$ssid.'&';} ?>page=<?php echo ($page+1); ?>&keywords=<?php echo $_REQUEST[keywords]; ?>">下一页</a></li>
    <?php }

    if ($totalPage>1) { //下一页 ?>
    <li><a href="?<?php if($_REQUEST[t]=='users' && $_REQUEST[uid]){echo 't=users&uid='.$usid.'&';}else{echo 't=shops&sid='.$ssid.'&';} ?>page=<?php echo $totalPage; ?>&keywords=<?php echo $_REQUEST[keywords]; ?>">尾页</a></li>

    <?php }?>


  </ul>

</div>           
</div>
</form>
</body>
<script type="text/javascript">
  function add(){
    window.location.href="addad.php";
  }
  $('.onS').on({
    click: function(){
      $('.onS').removeClass("sub_nav_active");
      $(this).addClass("sub_nav_active");
    },
  });

  // 查询
  $('.categroys').change(function(){
    var categroyid = $(this).val();
    var urls=window.location.href;
    if(getQueryString('cateid')){
      var currentUrls=urls.slice(0, urls.lastIndexOf('&'));
      window.location.href=currentUrls+'&cateid='+categroyid;
    }else{
      window.location.href = urls + '&cateid='+categroyid;
    }
  });
  // 查询 end

function getQueryString(param) {
  var reg = new RegExp("(^|&)" + param + "=([^&]*)(&|$)", "i"); 
  var r = window.location.search.substr(1).match(reg); 
  if (r != null) return unescape(r[2]); return null; 
} 
</script>
</html>
